/*
 * @Author: shuai
 * @Date: 2021-03-31 11:12:20
 * @LastEditors: shuai
 * @LastEditTime: 2021-03-31 14:09:15
 * @Description: file content
 */
import defaultSettings from '@/settings'
import { ActionContext } from 'vuex'
const { /* showSettings,*/ fixedHeader, sidebarLogo } = defaultSettings

const state = {
  // showSettings: showSettings,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo,
}

export type State = typeof state
const mutations = {
  CHANGE_SETTING: (state: State, { key, value }: { key: keyof State; value: State[keyof State] }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) state[key] = value
  },
}

const actions = {
  changeSetting({ commit }: ActionContext<State, unknown>, data: { key: keyof State; value: unknown }) {
    commit('CHANGE_SETTING', data)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
}
